

CROSS := i586-mingw32msvc-
# CROSS := i686-w64-mingw32-
CXX	:= $(CROSS)g++
LD	:= $(CROSS)g++
AR	:= $(CROSS)ar
CXXFLAGS := -Wall -O2 -Werror
INCLUDES = -Ilog -I. -Iwindow -Ipadtree

TARGET	= a.exe

LINKS	= -L.
LIBS	= -lgdi32 -luser32 -lws2_32 -luser32 -lcomctl32

SOURCES := CTApp.cc
SOURCES += MainFrame.cc
# SOURCES += CTNodeWin.cc

SOURCES += log/logging.cc
SOURCES += log/log_dispatcher.cc
SOURCES += log/logtracer_shell.cc

SOURCES += padtree/PadTree.cc

SOURCES += window/App.cc
SOURCES += window/Window.cc
SOURCES += window/WndProc.cc
SOURCES += window/WinMain.cc
SOURCES += window/Rect.cc
SOURCES += window/View.cc
# SOURCES += window/TreeView.cc
# SOURCES += window/ComboBox.cc
# SOURCES += window/Button.cc
# SOURCES += window/Edit.cc
# SOURCES += window/Static.cc

OBJS := $(SOURCES:.cc=.o)
DEPS := $(SOURCES:.cc=.d)

all: prebuild $(TARGET)

$(TARGET): $(OBJS)
	@echo Linking $@ ...
	$(LD) $(OBJS) $(LINKS) $(LIBS) -o$@
	@echo -------------------------------------------
	@echo done.

.cpp.o:
	@echo Compling $@ ...
	$(CXX) -c $< $(INCLUDES) $(CXXFLAGS)  -o $@
	@echo -------------------------------------------

.cc.o:
	@echo Compling $@ ...
	$(CXX) -c $< $(INCLUDES) $(CXXFLAGS)  -o $@
	@echo ------------------------------------------

%.d:%.cc
	$(CXX) -MM $< $(INCLUDES) $(CXXFLAGS) -o $@

prebuild:
	#echo -------

include $(DEPS)

clean:
	rm -fr $(OBJS) $(DEPS)



